import { Controller, Get, Inject, Query } from '@nestjs/common';
import { AppService } from './app.service';
import { ClientProxy } from '@nestjs/microservices';
import { Observable } from 'rxjs';

@Controller()
export class AppController {
  constructor(
    @Inject('sum_service') private calcClient:ClientProxy,
    private readonly appService: AppService
  ) {}

  @Get()
  getHello(@Query('num') str): Observable<number> {
    //return this.appService.getHello();
    const nums = str.split(',').map((item) => parseInt(item));
    return this.calcClient.send({cmd:'sum'},nums);
  }
}
